home *** CD-ROM | disk | FTP | other *** search
- /* header file for the stack allocation package. */
-
- #if !defined(STCKALLC_H)
- #define STCKALLC_H
-
- /* get definition of size_t */
- #include <stdlib.h>
-
- /* allocation stack. all fields are private */
- typedef struct
- {
- /* number of ALIGN_TYPEs in each allocation element */
- size_t n_units_in_element;
- /* pointer to linked list of blocks */
- void *block_list;
- /* index of next free ALIGN_TYPE in current block */
- size_t free;
- /* number of ALIGN_TYPEs in each block */
- size_t n_units_in_block;
- }
- ALLOC_STACK;
-
- /* initialize allocation stack */
- void init_alloc_stack
- (
- /* pointer to allocation stack to initialize */
- ALLOC_STACK *as,
- /* sizeof elements to be allocated */
- size_t elem_size
- );
-
- /* allocate an element from the allocation stack. returns null if
- insufficient memory available */
- void *get_alloc_stack
- (
- /* pointer to allocation stack */
- ALLOC_STACK *as
- );
-
- /* return address of last element allocated */
- void *look_alloc_stack
- (
- /* pointer to allocation stack */
- const ALLOC_STACK *as
- );
-
- /* free last element allocated */
- void free_alloc_stack
- (
- /* pointer to allocation stack */
- ALLOC_STACK *as
- );
-
- /* free all elements allocated */
- void clear_alloc_stack
- (
- /* pointer to allocation stack */
- ALLOC_STACK *as
- );
-
- #endif
-